module MC.View {
	export class Staff {
		public constructor() {
			this.init();
		}
		private zw: MC.View.ZhiweiDiv;
		private list: MC.Page = null;
		private init() {
		    let info=MC.user.info;
			if(info.is_company==0&&info.is_factory==0){
				MC.msg.alert('您没有启用公司或者工厂权限,无法查看简历',()=>{
					MC.back();
				});
				return;
			}
			this.zw = new MC.View.ZhiweiDiv(() => {
				this.zw.close = false;
			//	this.select();
				$('#staffPage #staffTitle .selectbtn').show();
			});
			$('#staffPage #staffTitle .selectbtn').on('click', () => {
				this.select();
			});

			this.loadUl();
		}

		public select() {
			$('#staffPage #staffTitle .selectbtn').hide();
			this.zw.selectVal((sel: any) => {
				console.log(sel);
				$('#staffPage #staffTitle .selectbtn').show();
				this.loadUl(sel.id);
			});
		}

		private loadUl(id: string='') {
			console.log(id);
			$('#jobDetail .jobs_ul').html('');
			////api/home/staff?cate=1
			this.list = new MC.Page("#jobPage", 'jianli_list', { job: id }, (resData: any, page: number) => {
				if (page == 0 && resData.length == 0) {
					var h = '';
					h += '<table class="toJobShow">';
					h += '<tr>';
					h += '<td colspan="2" style="text-align:center;">没有信息</td>';
					h += '</tr>';
					h += '</table>';
					$('#jobDetail .jobs_ul').html(h);
					$('.btn').hide();
					return;
				} else {
					this.jobs_ul('#jobDetail .jobs_ul', resData);
					console.log(resData);
				}
			});
			this.list.init();
		}


		private jobs_ul(jselect: string, list: any) {
			let jq = $(jselect);
			for (let i = 0; i < list.length; i++) {
				let obj = list[i];
				let li = `<li class="jobli">
                    <div class="jcon">
                        <a class="jobli_a" href="/h5/index/staffShow.html?id=`+ obj.uid + `"><div class="top clearfix">
                            <span class="jobName">`+ obj.job_str + `</span>
                            <span class="emolument">期望月薪¥`+ obj.salary + `元</span>
                        </div></a>
                        <p class="desc skill">`+ obj.residential_address + `</p>
                        <div class="tablist">
                            <a class="tabone">`+ obj.sex + `</a>
							<a class="tabone">`+ obj.education + `</a>
                        </div>
                         <a class="jobli_a" href="/h5/index/staffShow.html?id=`+ obj.uid + `">
						 <div class="userinfo clearfix">
                            <div class="headdiv">
                                <img src="`+ obj.image + `"
                                     class="head" />
                            </div>
                            <div class="usernameDiv">
                                <span class="company_name">`+ obj.realname + `</span>
                                <span class="uname">`+ obj.name + `</span>
                            </div>

                        </div>
						</a>
                    </div>
                </li>`;
				jq.append(li);
			}
		}
	}
}